/**
  ******************************************************************************
  * @file    global.c 
  * @author  Dajin Li
  * @version V0.0.1
  * @date    08-08-2015 
  * @brief   This file contains global definitions 
  *          
  ******************************************************************************
  * @attention
  *
  * <h2><center>&copy; KION(SZ) R&D Center
  *
  * Licensed under KION, (the "License");
  *
  ******************************************************************************
  */

/* Includes ------------------------------------------------------------------*/
#include "global.h"
#include "stm32f10x.h"


u8 CAN_Time_Out = 0;




u16 date_code;
u16 hardware_revision;
u16 key_status_op;
s8  LCD_Bklight = 50;
u16 Buzzer_Status;		//control the buzzer out put



/**
* @brief	delay function
* @param	u16 time: delay time
* @param	none
* @note     none
* @retval   none
*/
void Delay (u16 time)
{
	vu16 j;
	
	IWDG_ReloadCounter();
	for(j = 0; j < time; j++)
    {
        ;
    }
	IWDG_ReloadCounter();
}

/**
* @brief	lookup KWP2000 obejct id 
* @param	const s32 *table
* @param	s16 length
* @param	s32 target
* @note     none
* @retval   none
*/
s16 lookup_object_id(kwp_data_st *table, s16 length, s32 target)
{
    int high = length;
    int low = -1;
    int probe = 0;

    while (high - low > 1) 
    {                                  
        probe = (high + low) / 2;       
        if (table[probe].kwp_id < target)
        {
            low = probe;
        }
        else
        {
            high = probe;
        }
    }

    if (high == length || table[high].kwp_id != target) 
    {
        return -1;                     
    }
    else
    {
        return high;                    
    }
}




